package com.cll.netty.netty.inboundlerAndOutboundhandler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class MyLongToByteEncoder extends MessageToByteEncoder<Long> {

    // 编码方法
    @Override
    protected void encode(ChannelHandlerContext ctx, Long msg, ByteBuf byteBuf) throws Exception {
        System.out.println("MyLongToByteEncoder encode 被调用 ");
        System.out.println("msg=" + msg);
        byteBuf.writeLong(msg);
    }
}
